
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>谈谈Dubbo的负载均衡策略 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>谈谈Dubbo的负载均衡策略 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Dubbo中，应如何根据具体场景选择“最少活跃调用数”和“一致性哈希”这两种负载均衡策略？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当服务处理时间差异较大或并发波动剧烈时，应选择“最少活跃调用数”策略，因为它能动态感知实时负载。而在需要保证请求幂等性或用于分布式缓存以提高命中率的场景中，“一致性哈希”策略是更好的选择。</div>
          </div>
          <div class="card-source">来源: 文档引言部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Dubbo的随机负载均衡（Random LoadBalance）策略是如何工作的？当服务提供者设置了权重时，其行为有何变化？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">该策略会在可用的服务提供者列表中随机选择一个来处理请求。如果设置了权重（Weight），则会根据权重值进行加权随机，即权重越高的服务提供者被选中的概率越大。</div>
          </div>
          <div class="card-source">来源: 1. Random LoadBalance（随机负载均衡）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">轮询负载均衡（RoundRobin LoadBalance）策略的主要缺点是什么，这使其不适合在哪些场景下使用？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">主要缺点是它没有考虑服务提供者的实时负载和处理能力，可能导致部分实例在高并发情况下超载。因此，它不适合高并发和动态变化的场景。</div>
          </div>
          <div class="card-source">来源: 2. RoundRobin LoadBalance（轮询负载均衡）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">“最少活跃调用数”（LeastActive）负载均衡策略的核心原理是什么？它如何实现动态负载均衡？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">其核心原理是将请求分发给当前正在处理请求数量最少的服务提供者。它通过动态感知各个服务提供者的实时负载情况，将更多请求分配给负载较低的实例，从而实现更优的负载均衡。</div>
          </div>
          <div class="card-source">来源: 3. LeastActive LoadBalance（最少活跃调用数负载均衡）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">什么是一致性哈希（ConsistentHash）负载均衡策略？它为何特别适用于分布式缓存场景？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">一致性哈希策略通过对请求参数进行哈希计算，将相同参数的请求始终定位到同一个服务提供者。这能确保请求被路由到同一节点，从而在分布式缓存场景中有效提高缓存命中率。</div>
          </div>
          <div class="card-source">来源: 4. ConsistentHash LoadBalance（一致性哈希负载均衡）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">相较于随机和轮询策略，“最少活跃调用数”策略在实现上有什么额外的开销？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">它需要额外维护每个服务提供者的活跃调用数，这增加了一定的计算开销。同时，在瞬时高并发场景下，它也可能导致某些实例的负载激增。</div>
          </div>
          <div class="card-source">来源: 3. LeastActive LoadBalance（最少活跃调用数负载均衡）</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
